package com.lmm.rpc.core.cluster;

import java.util.List;
import java.util.Random;

/**
 * @title: RandomBalance
 * @Description: 随机负载均衡
 * @Author Lmm
 * @Date: 2022/10/8 18:24
 * @Version 1.0
 */
public class RandomBalance extends AbstractLoadBalancer{
    @Override
    protected RemoteServerInfo doSelect(List<RemoteServerInfo> enableList) {
        if (enableList == null || enableList.size() == 0)
            return null;
        Random random = new Random();
        return enableList.get(random.nextInt(enableList.size()));
    }
}
